/* model */
import MsgModel from '@model/MsgModel';
import { 
  BaseSelectUserMarkTypeEnum,
  SelectUserDepartment,
  SelectUserProjectTeam,
  SelectUser,
  SelectUserLabel, 
  SelectUserRole,
  SelectUserServiceProvider,
  SelectUserState,
  SelectUserComponentDepartment,
  SelectUserComponentRole,
  SelectUserComponentProjectTeam,
  SelectUserComponentServiceProvider,
  SelectUserComponentUser,
  BaseSelectUserOptions,
  BaseSelectUserResult,
  BaseSelectUserSearchMoreTypeEnum
} from '@src/component/common/BaseSelectUser/model'

// 获取选人组件 tabs 选项卡 列表的参数模型
type BaseSelectUserGetMarkListModel = {
  // 是否显示服务商
  showSp: boolean;
  // 服务商成员是否显示部门
  showTagIfSpUser: boolean;
}

// 获取选人组件 tabs 选项卡 列表的返回数据类型
type BaseSelectUserGetMarkListResult = BaseSelectUserMark[]

// 选人组件 服务商资质 类型
type SelectUserServiceProviderQualificationType = string;

// 选人组件 服务商类型 类型
type SelectUserServiceProviderTypeType = string;

// 选人控件的查询标签
type BaseSelectUserMark = {
  // 类型
  type: BaseSelectUserMarkTypeEnum,
  // 显示名称
  name: string;
}

type BaseSelectUserGetSearchUserListBaseModel = {
  keyword: string;
  // 是否显示删除用户
  showDelete: boolean;
  // 当前用户为服务商成员时，是否显示 部门用户数据
  showTagIfSpUser: boolean;
  // 是否显示待分配的人员
  showNoDistribute: boolean;
}

// 选人组件 搜索查询人员列表 模型
type BaseSelectUserGetSearchUserListModel = BaseSelectUserGetSearchUserListBaseModel & {
  // 是否显示组织架构的人员
  showOrg: boolean;
  // 是否显示服务商的人员
  showSp: boolean;
  // 当前用户为服务商成员时，是否显示 部门用户数据
  showTagIfSpUser: boolean;
  // 区分全部和团队权限
  authKey?: string; 
}

// 选人组件 页 模型
type BaseSelectUserPageModel = {
  // 页码数
  pageNum: number;
  // 页大小
  pageSize: number;
}

// 选人组件 查询人员列表 模型
type BaseSelectUserGetUserListModel = {
  // 角色 id | 服务商 id
  id: string;
  // 工作状态 列表
  stateList: string[];
} & BaseSelectUserPageModel;

// 选人组件 查询人员列表 标签 模型
type BaseSelectUserGetUserListModelLabel = {
  // 人员标签 id 列表
  labelIdList: number[];
}

// 选人组件 查询部门人员列表 模型
type BaseSelectUserGetDepartmentUserListModel = BaseSelectUserGetUserListModel & BaseSelectUserGetUserListModelLabel &  {
  typeId: number | null;
  // 是否显示用户列表 (默认为 true)
  showUser: boolean;
  // 是否显示待分配的人员
  showNoDistribute: boolean;
};

// 选人组件 搜索更多人员列表 模型
type BaseSelectUserGetSearchMoreUserListModel = BaseSelectUserGetSearchUserListBaseModel & BaseSelectUserPageModel & {
  clickType: BaseSelectUserSearchMoreTypeEnum;
  // 是否显示删除用户
  showDelete: boolean;
}

// 项目模板 - 入参
type BaseSelectUserGetProjectTeamListModel = {
  projectId: string
}

// 选人组件 查询角色人员列表 模型
type BaseSelectUserGetRoleUserListModel = BaseSelectUserGetUserListModel & BaseSelectUserGetUserListModelLabel;

// 选人组件 查询服务商人员列表 模型
type BaseSelectUserGetServiceProviderUserListModel = BaseSelectUserGetUserListModel;

// 选人组件 查询项目组成员列表 模型
type BaseSelectUserGetProjectTeamUserListModel = BaseSelectUserGetProjectTeamListModel;

// 选人组件 查询角色人员列表 基础返回数据类型
type BaseSelectUserGetUserListResult = {
  // 人员列表
  userList: SelectUser[];
  // 人员总数
  userTotalCount: number;
}

// 选人组件 查询部门列表 返回数据类型
type BaseSelectUserGetDepartmentListResult = SelectUserDepartment[]

// 选人组件 查询工作列表 返回数据类型
type BaseSelectUserGetStateListResult = SelectUserState[]

// 选人组件 查询人员标签列表 返回数据类型
type BaseSelectUserGetLabelListResult = SelectUserLabel[]

// 选人组件 查询角色列表 返回数据类型
type BaseSelectUserGetRoleListResult = SelectUserRole[]

// 选人组件 查询服务商列表 返回数据类型
type BaseSelectUserGetServiceProviderListResult = SelectUserServiceProvider[]

// 选人组件 查询服务商资质列表 返回数据类型
type BaseSelectUserGetServiceProviderQualificationListResult = SelectUserServiceProviderQualificationType[]

// 选人组件 查询服务商类型列表 返回数据类型
type BaseSelectUserGetServiceProviderTypeListResult = SelectUserServiceProviderTypeType[]

// 选人组件 查询角色人员列表 返回数据类型
type BaseSelectUserGetRoleUserListResult = BaseSelectUserGetUserListResult

// 选人组件 查询项目组列表 返回数据类型
type BaseSelectUserGetProjectTeamListResult = SelectUserProjectTeam[]

// 选人组件 查询项目组人员列表 返回数据类型
type BaseSelectUserGetProjectTeamUserListResult = SelectUserComponentProjectTeam[]

// 选人组件 查询服务商人员列表 返回数据类型
type BaseSelectUserGetServiceProviderUserListResult = BaseSelectUserGetUserListResult & {
  tagChildren: SelectUserServiceProvider[];
}

// 选人组件 查询部门人员列表 返回数据类型
type BaseSelectUserGetDepartmentUserListResult = {
  tagChildren: SelectUserDepartment[];
  userList: SelectUser[];
  userTotalCount: number;
}

// 选人组件 搜索人员 返回数据类型
type BaseSelectUserGetSearchUserListResult = {
  // 组织架构人员列表
  organizationList: SelectUser[];
  // 组织架构人员列表是否含有更多
  organizationHasMore: boolean;
  // 服务商人员列表
  spUserList: SelectUser[];
  // 服务商人员列表是否含有更多
  spHasMore: boolean;
}

type BaseSelectUserGetSearchMoreUserListResult = BaseSelectUserGetUserListResult;

type BaseSelectUserSelectedItemType = SelectUserComponentDepartment | SelectUserComponentUser | SelectUserComponentRole | SelectUserComponentServiceProvider | SelectUserComponentProjectTeam;

// 选人组件 筛选表单 基础类型
type BaseSelectUserFilterForm = {
  stateList: string[];
  qualificationManagement:any[]
}

// 选人组件 部门筛选表单数据类型
type BaseSelectUserFilterDepartmentForm = BaseSelectUserFilterForm & {
  // 人员标签 id 列表
  labelIdList: string[];
  // 部门名称
  tagName: string;
}

// 选人组件 角色筛选表单数据类型
type BaseSelectUserFilterRoleForm = BaseSelectUserFilterForm & {
  // 人员标签 id 列表
  labelIdList: string[];
  // 角色名称
  roleName: string;
}

// 选人组件 服务商筛选表单数据类型
type BaseSelectUserFilterServiceProviderForm = BaseSelectUserFilterForm & {
  // 服务商资质列表
  spList: string[];
  // 服务商类型列表
  spTypeList: string[];
  // 服务商名称
  spName: string;
  // 当前状态
  stateList: string[];
}

enum BaseSelectUserFilterServiceProviderFormValue {
  spList = '',
  spTypeList = '',
  spName = '',
  stateList = '',
}

// 获取选人组件 部门列表的参数模型
type BaseSelectUserGetDepartmentListModel = BaseSelectUserFilterDepartmentForm & BaseSelectUserPageModel & {
  // 是否显示已删除 (默认为 true)
  showDelete: boolean;
  // 是否显示用户列表 (默认为 true)
  showUser: boolean;
  // 没有默认值，如果传了参数，就以前端的参数为准，如果没传，就以租户的配置为主
  isTag?: boolean;
  // 区分全部和团队权限
  authKey?: string; 
}

// 获取选人组件 角色列表的参数模型
type BaseSelectUserGetRoleListModel = BaseSelectUserFilterRoleForm & {
  // 是否显示未分配
  showNoDistribute: boolean;
};

// 获取选人组件 服务商列表的参数模型
type BaseSelectUserGetServiceProviderListModel = BaseSelectUserFilterServiceProviderForm & {
  // 是否显示已注销的服务商
  showCancel: boolean;
  // 服务商是否显示全部
  showSpAll: boolean;
  // 服务商名称模糊查询字段
  spName: string;
  // 区分全部和团队权限
  authKey?: string;
  // 服务商是否隐藏没有工程师的
  hideNullProvider?: boolean;
};

type BaseSelectUserSelectedType = SelectUser[] | BaseSelectUserSelectedObjectType | undefined;

type BaseSelectUserSelectedObjectType = {
  users?: SelectUser[];
  depts?: SelectUserDepartment[];
  teams?: SelectUserDepartment[];
}

// 选人组件 默认配置类型
type BaseSelectUserDefaultOptionsType = {
  isCanChooseUser: boolean;
  isCanChooseDepartment: boolean;
  isCanChooseRole: boolean;
  isCanChooseServiceProvider: boolean;
}

// 选人组件 单选-选人 默认配置类型
type BaseSelectUserSingleUserDefaultOptionsType = {
  max: number;
  selectedUsers: SelectUserComponentUser[];
} & BaseSelectUserDefaultOptionsType & BaseSelectUserMultiUserDefaultOptionsType;

// 选人组件 多选-选人 默认配置类型
type BaseSelectUserMultiUserDefaultOptionsType = {
  selectedDepartments: SelectUserComponentDepartment[];
  selectedRoles: SelectUserComponentRole[];
  selectedServiceProviders: SelectUserComponentServiceProvider[];
} & BaseSelectUserDefaultOptionsType;

// 选人组件 多选-部门 默认配置类型
type BaseSelectUserMultiDepartmentDefaultOptionsType = {
  selectedUsers: SelectUserComponentUser[];
  selectedRoles: SelectUserComponentRole[];
  selectedServiceProviders: SelectUserComponentServiceProvider[];
  showRole: boolean;
  showDelete: boolean;
  isShowUser: boolean;
  isShowSearch: boolean;
  showServiceProvider: boolean;
} & BaseSelectUserDefaultOptionsType;

// 选人组件 多选-部门人员 默认配置类型
type BaseSelectUserMultiDepartmentUserDefaultOptionsType = {
  selectedUsers: SelectUserComponentUser[];
  selectedRoles: SelectUserComponentRole[];
  selectedServiceProviders: SelectUserComponentServiceProvider[];
  showRole: boolean;
  showDelete: boolean;
  isShowUser: boolean;
  isShowSearch: boolean;
  showServiceProvider: boolean;
} & BaseSelectUserDefaultOptionsType;

// 选人组件 多选-部门和角色 默认配置类型
type BaseSelectUserMultiDepartmentAndRoleDefaultOptionsType = {
  selectedUsers: SelectUserComponentUser[];
  selectedServiceProviders: SelectUserComponentServiceProvider[];
  showServiceProvider: boolean;
  showDelete: boolean;
  isShowUser: boolean;
  isShowSearch: boolean;
} & BaseSelectUserDefaultOptionsType;

// 选人组件 多选-服务商 默认配置类型
type BaseSelectUserMultiServiceProviderDefaultOptionsType = {
  selectedDepartments: SelectUserComponentDepartment[];
  selectedRoles: SelectUserComponentRole[];
  selectedUsers: SelectUserComponentUser[];
  showServiceProvider: boolean;
  showDelete: boolean;
  isShowUser: boolean;
  isShowSearch: boolean;
  showCancel: boolean;
  showRole: boolean;
  showDepartment: boolean;
} & BaseSelectUserDefaultOptionsType;

// 选人组件 多选-部门和人 默认配置类型
type BaseSelectUserMultiDepartmentAndUserDefaultOptionsType = {
  selectedRoles: SelectUserComponentRole[];
  selectedServiceProviders: SelectUserComponentServiceProvider[];
} & BaseSelectUserDefaultOptionsType;

// 选人组件 多选-全部 默认配置类型
type BaseSelectUserMultiAllDefaultOptionsType = BaseSelectUserDefaultOptionsType;

// 选人组件 单选-选人 配置类型
type BaseSelectUserSingleUserOptionsType = Omit<BaseSelectUserOptions, keyof BaseSelectUserSingleUserDefaultOptionsType>;
// 选人组件 多选-选人 配置类型
type BaseSelectUserMultiUserOptionsType = Omit<BaseSelectUserOptions, keyof BaseSelectUserMultiUserDefaultOptionsType>;
// 选人组件 多选-部门 配置类型
type BaseSelectUserMultiDepartmentOptionsType = Omit<BaseSelectUserOptions, keyof BaseSelectUserMultiDepartmentDefaultOptionsType>;
// 选人组件 多选-部门人员 配置类型
type BaseSelectUserMultiDepartmentUserOptionsType = Omit<BaseSelectUserOptions, keyof BaseSelectUserMultiDepartmentUserDefaultOptionsType>;
// 选人组件 多选-部门和角色 配置类型
type BaseSelectUserMultiDepartmentAndRoleOptionsType = Omit<BaseSelectUserOptions, keyof BaseSelectUserMultiDepartmentAndRoleDefaultOptionsType>;
// 选人组件 多选-部门和人 配置类型
type BaseSelectUserMultiDepartmentAndUserOptionsType = Omit<BaseSelectUserOptions, keyof BaseSelectUserMultiDepartmentAndUserDefaultOptionsType>;
// 选人组件 多选-服务商 配置类型
type BaseSelectUserMultiServiceProviderOptionsType = Omit<BaseSelectUserOptions, keyof BaseSelectUserMultiServiceProviderDefaultOptionsType>;
// 选人组件 多选-全部 配置类型
type BaseSelectUserMultiAllOptionsType = Omit<BaseSelectUserOptions, keyof BaseSelectUserMultiAllDefaultOptionsType>;

// 选人组件 方法返回值类型
type BaseSelectUserComponentResultType = Promise<MsgModel<BaseSelectUserResult>>;

type BaseSelectUserCascaderOptionItemType = {
  value: string;
  label: string;
  children: BaseSelectUserCascaderOptionItemType[]
}

export type {
  BaseSelectUserGetMarkListResult,
  BaseSelectUserMark,
  BaseSelectUserGetDepartmentListModel,
  BaseSelectUserGetRoleListModel,
  BaseSelectUserGetServiceProviderListModel,
  BaseSelectUserGetDepartmentListResult,
  BaseSelectUserGetStateListResult,
  BaseSelectUserGetLabelListResult,
  BaseSelectUserGetSearchUserListModel,
  BaseSelectUserGetUserListResult,
  BaseSelectUserGetRoleListResult,
  BaseSelectUserGetServiceProviderListResult,
  BaseSelectUserGetServiceProviderQualificationListResult,
  SelectUserServiceProviderQualificationType,
  BaseSelectUserGetRoleUserListModel,
  BaseSelectUserGetProjectTeamListModel,
  BaseSelectUserGetServiceProviderUserListModel,
  BaseSelectUserGetProjectTeamUserListModel,
  BaseSelectUserGetRoleUserListResult,
  BaseSelectUserGetProjectTeamListResult,
  BaseSelectUserGetProjectTeamUserListResult,
  BaseSelectUserGetServiceProviderUserListResult,
  BaseSelectUserGetSearchUserListResult,
  BaseSelectUserSelectedItemType,
  BaseSelectUserFilterDepartmentForm,
  BaseSelectUserFilterRoleForm,
  BaseSelectUserFilterServiceProviderForm,
  BaseSelectUserFilterServiceProviderFormValue,
  BaseSelectUserGetServiceProviderTypeListResult,
  SelectUserServiceProviderTypeType,
  BaseSelectUserGetDepartmentUserListResult,
  BaseSelectUserGetDepartmentUserListModel,
  BaseSelectUserSelectedType,
  BaseSelectUserSelectedObjectType,
  BaseSelectUserSingleUserOptionsType,
  BaseSelectUserMultiUserOptionsType,
  BaseSelectUserMultiDepartmentOptionsType,
  BaseSelectUserMultiDepartmentAndUserOptionsType,
  BaseSelectUserMultiAllOptionsType,
  BaseSelectUserSingleUserDefaultOptionsType,
  BaseSelectUserMultiUserDefaultOptionsType,
  BaseSelectUserMultiDepartmentDefaultOptionsType,
  BaseSelectUserMultiDepartmentAndUserDefaultOptionsType,
  BaseSelectUserMultiAllDefaultOptionsType,
  BaseSelectUserComponentResultType,
  BaseSelectUserGetMarkListModel,
  BaseSelectUserMultiDepartmentAndRoleOptionsType,
  BaseSelectUserMultiDepartmentAndRoleDefaultOptionsType,
  BaseSelectUserGetSearchMoreUserListModel,
  BaseSelectUserGetSearchMoreUserListResult,
  BaseSelectUserMultiServiceProviderOptionsType,
  BaseSelectUserMultiServiceProviderDefaultOptionsType,
  BaseSelectUserMultiDepartmentUserDefaultOptionsType,
  BaseSelectUserMultiDepartmentUserOptionsType,
  BaseSelectUserCascaderOptionItemType
}
